<?php

namespace Jb\Navigation;

use Jb\Navigation\Menu,
    Jb\Navigation\RootMenu,
    Jb\Navigation\Page,
    Jb\Utils\Web\Uri,
    Jb\Utils\Comparison;

// Wrong usage.... Maybe turn into builder...
class NavigationBuilder {

    private $rootMenu;
    private $currentMenu;

    public function __construct() {
        $rootMenu = new RootMenu('Westra');
        $rootMenu->addRoute(new Route(new Comparison\Strategy\String(null)));
        $this->rootMenu = $rootMenu;
        $this->currentMenu = $rootMenu;
    }

    public function getNavigation() {
        return $this->rootMenu;
    }

    /**
     *
     * @param string $menuLabel
     * @param array $menuRoutes
     * @param string $menuUri
     * @return NavigationBuilder
     */
    public function buildMenu($menuLabel, array $menuRoutes = array(), $menuUri = null) {
        $oMenu = new Menu($menuLabel);

        if(count($menuRoutes) > 0) {
            foreach($menuRoutes as $menuRoute) {
                $oMenu->addRoute(new Route($menuRoute));
            }
        }

        $this->currentMenu->getParent()->addPage($oMenu);
        $this->currentMenu = $oMenu;
        return $this;
    }

    /**
     *
     * @param string $pageLabel
     * @param string $pageUri
     * @param array $pageRoutes
     * @return NavigationBuilder
     */
    public function buildPage($pageLabel, $pageUri, array $pageRoutes = array()) {
        $oPage = new Page($pageLabel);
        $oUri = new Uri($pageUri);
        $oPage->setUri($oUri);

        // A pages Uri is also a Route wich can be used to compare against the current page Route
        $oPage->addRoute(new Route(new Comparison\Strategy\String($oUri->toString())));

        if(count($pageRoutes) > 0) {
            foreach($pageRoutes as $pageRoute) {
                $oPage->addRoute(new Route($pageRoute));
            }
        }        

        $this->currentMenu->addPage($oPage);
        return $this;
    }

    public function buildBreadcrumbs(Menu $rootMenu) {
        $breadcrumbMenu = new Breadcrumbs\BreadcrumbMenu($rootMenu);
        

    }


}

?>